package com.luosonxin.converter;

import org.springframework.core.convert.converter.Converter;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.concurrent.ConcurrentMap;

public class MyStringToDateConverter implements Converter<String, Date> {
       @Override
    public Date convert(String source) {
           if (source == null || "".equals(source)){
               return null;
           }
           DateFormat dateFormat = new SimpleDateFormat("yyyy-mm-dd");
           try {
               return dateFormat.parse(source);
           }catch (Exception e){
               e.printStackTrace();
           }
        return null;
    }
}
